#include <stdio.h>
#include <string.h>

int get_host_from_url(const char *url, char *host)
{
	char *prot_start = strstr(url, "//");
	if (!prot_start)
		return -1;
	prot_start += strlen("//");
	char *prot_end = strchr(prot_start, '/');
	if (!prot_end)
		prot_end = prot_start + strlen(prot_start);
	strncpy(host, prot_start, prot_end - prot_start);
	host[prot_end - prot_start - 1] = '\0';
	return 0;
}
